package com.china.produce.factorys;

import org.apache.ibatis.session.SqlSession;
import org.springframework.beans.factory.FactoryBean;

/**
 * @ClassName
 * @Author niujie
 * @Version
 * @Description
 * @CreateTime 2023/1/20
 */
public class MapperFactoryBean implements FactoryBean {

    private Class mapperClass;

    private SqlSession sqlSession;

    public  MapperFactoryBean(Class mapperClass) {

        this.mapperClass = mapperClass;
    }

    public void setSqlSession(SqlSession sqlSession) {

        this.sqlSession = sqlSession;
    }

    @Override
    public Object getObject() throws Exception {

        System.out.println("11 --" + mapperClass);

        return  sqlSession.getMapper(mapperClass);
    }

    @Override
    public Class<?> getObjectType() {

        return mapperClass.getClass();
    }
}
